package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.model.User;
import com.esm.service.UserService;
import com.esm.serviceimpl.UserServiceImpl;
import com.esm.utils.PrintWriterUtil;

import net.sf.json.JSONObject;

public class GetAEmployeeController_wcj extends HttpServlet
{
private static final long serialVersionUID = 1L;
	
	UserService uService = new UserServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		int uid = Integer.parseInt(req.getParameter("uid"));
		User user = uService.getDempByUid(uid);
		JSONObject jo = new JSONObject();
		jo.put("emp", user);
		PrintWriter pw = resp.getWriter();
		PrintWriterUtil.flushJoAndClosePrintWriter(pw, jo);
	}
}
